<template>
  <div class="card">
    <div class="card-header">
      <img :src="article.coverImg" class="card-image" v-if="article.coverImg">
      <div class="image-default" v-else>
        <i class="el-icon-picture-outline"></i>
      </div>
    </div>

    <div class="card-body">
      <h5 class="card-title">{{article.title}}</h5>
      <div class="card-info">
        <div class="card-time"><i class="el-icon-date"></i>{{article.time}}</div>
        <div class="card-type"><i class="el-icon-document"></i>{{article.type}}</div>
      </div>
      <p class="card-text">{{article.intro}}</p>
    </div>
    <div class="card-footer">
      <div class="right">
        <router-link :to="'/detail/'+article.id" class="to-detail">查看详情</router-link>
      </div>
    </div>
  </div>
</template>

<script>
import coverImg from "../assets/avatar.png";
export default {
  name: "ArticleIntroduceCard",
  props: {
    article: {type: Object, required: true}
  },
  data() {
    return {
      /*article: {
        id: '2',
        title: '标题',
        time: '2022-03-01 20:14:52',
        intro: '内容简要...',
        coverImg: '/static/avatar.png'
      }*/
    }
  }
}
</script>

<style scoped lang="less">
  .card {
    height: 460px;
    display: flex;
    flex-direction: column;
    //align-items: center;
    justify-content: center;
    width: 300px;
    background-color: #fff;
    border-radius: 6px;
    box-sizing: border-box;
    margin: 10px;
    .card-header {
      width: 300px;
      height: 200px;
      .card-image, .image-default {
        border-radius: 6px 6px 0 0;
        width: 300px;
        height: 200px;
      }
      .image-default {
        background-color: #ccc;
        text-align: center;
        line-height: 200px;
        i {
          font-size: 36px;
        }
      }
    }
    .card-body {
      padding: 6px 10px;
      height: 200px;
      .card-title {
        font-size: 20px;
        line-height: 24px;
        margin: 10px 0;
      }
      .card-info {
        .card-time, .card-type {
          float: left;
          font-size: 14px;
          line-height: 20px;
          margin: 10px 0 10px 8px;
          color: #bbb;
          i {
            margin-right: 4px;
          }
        }
      }
      .card-info::after {
        content: "";
        height: 0;
        line-height: 0;
        display: block;
        visibility: hidden;
        clear: both;
      }
      .card-text {
        font-size: 14px;
        height: 60px;
        line-height: 20px;
        margin: 10px 0;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
      }
    }
    .card-footer {
      line-height: 20px;
      padding: 10px;
      .right {
        float: right;
        width: 80px;
        text-align: center;
        background: #24ADF3;
        padding: 10px;
        border-radius: 5px;
        .to-detail {
          text-decoration: none;
          color: #fff;
        }
      }
    }
  }
</style>
